import cv2 as cv
import numpy as np


def main():
    cap = cv.VideoCapture(0)

    while True:
        _, frame = cap.read()
        hsv = cv.cvtColor(frame, cv.COLOR_BGR2HSV)

        lower_blue = np.array([110, 45, 50])
        upper_blue = np.array([130, 255, 255])

        mask = cv.inRange(hsv, lower_blue, upper_blue)
        res = cv.bitwise_and(frame, frame, mask=mask)

        cv.imshow('[frame]Press Q to exit', frame)
        cv.imshow('[mask]Press Q to exit', mask)
        cv.imshow('[res]Press Q to exit', res)

        if cv.waitKey(1) == ord('q'):
            break

    cap.release()
    cv.destroyAllWindows()


if __name__ == "__main__":
    main()
